#include "clearClueCardParam.h"
#include "jsonUtils.h"

ClearClueCardParam::ClearClueCardParam(const int64_t& movieId, const int64_t& clueCardId, const int& channel, const String& clueType)
	: movieId(movieId), clueCardId(clueCardId), channel(channel), clueCardType(clueType)
{
}

const int64_t& ClearClueCardParam::getMovieId() const
{
	return movieId;
}

const int64_t& ClearClueCardParam::getClueCardId() const
{
	return clueCardId;
}

const int& ClearClueCardParam::getChannel() const
{
	return channel;
}

const String& ClearClueCardParam::getClueCardType() const
{
	return clueCardType;
}

void ClearClueCardParam::fromJson(const String& json)
{
	if (!json.empty()) {
		JsonDoc doc;
		doc.Parse(json.c_str());
		JsonUtils::loadLong(doc, L"movieId", movieId);
		JsonUtils::loadLong(doc, L"clueCardId", clueCardId);
		JsonUtils::loadStr(doc, L"clueCardType", clueCardType);
		JsonUtils::loadInt(doc, L"channel", channel);
	}
}

String ClearClueCardParam::toJson()
{
	JsonDoc doc;
	doc.SetObject();
	doc.AddMember(L"movieId", movieId, doc.GetAllocator());
	doc.AddMember(L"clueCardId", clueCardId, doc.GetAllocator());
	JsonUtils::addString(doc, L"clueCardType", clueCardType, doc.GetAllocator());
	doc.AddMember(L"channel", channel, doc.GetAllocator());
	return JsonUtils::jsonStr(doc);
}
